-
Notifications
You must be signed in to change notification settings - Fork 28
New Architecture with greater flexibility + Auto Capture worker + Initial API Client #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lmtr0
wants to merge
35
commits into
PostHog:main
Choose a base branch
from
lmtr0:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
feat/architecture
Extension Like client api
Base api client
Implementation of the Capture endpoint with a custom Event Builder
This change adds a new `capture` method to the `PostHogClient` struct. The `capture` method allows users to send event data to the PostHog `/capture/` endpoint. The method takes a `serde_json::Value` containing the event data and returns a `CaptureResponse` struct, which includes the status of the capture operation. The new `capture` method includes detailed documentation, including argument and return value descriptions, as well as an example usage. Additionally, the `CaptureEndpoints` trait and associated `CaptureResponse` struct have been moved to the `PostHogClient` implementation directly.
Fea/decide request
Better separation between sdk and api
This change introduces a new `PostHogAPIClient` struct that provides a convenient interface for making API requests to the PostHog platform. The client automatically handles rate limiting and retries, ensuring that API requests are processed reliably. The key features of this implementation include: - Automatic rate limit handling with exponential backoff - Retry mechanism with a configurable maximum number of retries - Support for both JSON-based and no-content API responses - Configurable base URL for the API endpoint - Abstraction of the underlying HTTP client (using `reqwest`) This client will be used throughout the PostHog SDK to interact with the PostHog API, providing a robust and user-friendly experience for SDK users.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello there, good day.
General Information
(Background) I needed a more flexible client with a support for auto capture, and I noticed that a lot of the work I was doing in my services was a bunch of boilerplate. With that in mind, I wanted to make it available to everybody so that you don't need to re-implement what I did.
This client includes an auto-capture actor that uses channels and tokio (no deadlocks) to make sure the only thing you need to worry about is the events and not the api client implementation.
There is an initial query api client that I implemented because I need it for my application.
I've features enabled so that you only enable the code you need.
The downside. I removed the code you just merged for blocking clients as I was developing the actor in parallel and it's too late to reverse it now.
This is a follow up on #24
If you want me to change anything let me know, I'll work on it as soon as I can.
Inner workings
I've included the architecture documents I used to develop some of the clients, and what I envision it to be. I've more of the api planned to the future, but, I only have so much time and I need to get the other products out. SO, I might re work some of this in the future